class Solution:
    def isRationalEqual(self, s: str, t: str) -> bool:
        def count(ss):
            if "(" not in ss:
                return float(ss)
            p1, p2, p3 = ss[:ss.index(".")], ss[ss.index(".") + 1:ss.index("(")], ss[ss.index("(") + 1:-1]
            return float(p1 + "." + p2) + int(p3 * 10) / pow(10, 10 * len(p3) + len(p2))

        return abs(count(s) - count(t)) < pow(10, -8)


if __name__ == "__main__":
    print(Solution().isRationalEqual(s="0.(52)", t="0.5(25)"))  # True
    print(Solution().isRationalEqual(s="0.1666(6)", t="0.166(66)"))  # True
    print(Solution().isRationalEqual(s="0.9(9)", t="1."))  # True
    print(Solution().isRationalEqual(s="1", t="0.99(99)"))  # True
    print(Solution().isRationalEqual(s="1.9(0)", t="1.8(9)"))  # True
    print(Solution().isRationalEqual(s="0.08(9)", t="0.09"))  # True
    print(Solution().isRationalEqual(s="15.(9)", t="16"))  # True
